﻿package monopoly.DBA.PHPRemoting {
	/* By Josh Strike // josh@joshstrike.com // Use freely and enjoy! */
	public class Remoting {
		
		public static var r:Object;
		public static var PHP:PHPAccess;
		
		private static var instance:Remoting; //This var should be deprecated, I think.//
		private static var allowInstantiation:Boolean;
				
		public static function getInstance(a:Object,gateway:String):Remoting {
			if (instance) {
				return instance;
			}
			allowInstantiation = true;
			instance = new Remoting(a,gateway);
			allowInstantiation = false;

			return (instance);
		}
		
		public function Remoting(a:Object,gateway:String):void {
			if (!allowInstantiation) {
				throw new Error("Error: Instantiation failed: Use SinglePHP.getInstance() instead of new.");
			}
			instantiate(a,gateway);
		}
		
		private function instantiate(a:Object,gateway:String) {
			r = a;
			//make this be your phpAccess instantiation line.
			//TPAZ - turn off debugging
			PHP = new PHPAccess(gateway,r.stage,false,r.stage.stageWidth,r.stage.stageHeight,10);
		}
	}
}